class Solution {
public:
    int jump(vector<int>& nums) {
        int len = nums.size();
        int* arr = new int[len];
        arr[0] = 0;
        for (int i = 1; i < len; i++)
        {
            int minnum = INT_MAX;
            for (int j = i - 1; j >= 0; j--)
            {

                if (j + nums[j] >= i)
                {
                    minnum = min(minnum, arr[j] + 1);
                }
            }
            arr[i] = minnum;
        }
        return arr[len - 1];
    }
};